#include<set>
#include<iostream>
using namespace std;


int main()
{
    int a[] = {3, 1, 2, 5, 7, 6};
    multiset<int> s1(a, a+6);  // 元素升序排列在集合中
    multiset<int>::iterator p = s1.begin();  // multiset 允许元素出现重复
    for(p = s1.begin(); p != s1.end(); p++)
        cout << *p << " ";
    cout << endl;

    s1.insert(3);  // 插入之后仍能够保持有序
    s1.insert(777);

    for(p = s1.begin(); p != s1.end(); p++)
        cout << *p << " ";
    cout << endl;

    p = s1.lower_bound(3);
    cout << *p << endl;
    p = s1.upper_bound(3);  // 返回最后一个元素的下一个位置的迭代器
    cout << *p << endl;

    p = s1.find(11);
    if(p == s1.end()) cout << "can't find" << endl;
    else cout << *p << endl;

    s1.erase(3);
    for(p = s1.begin(); p != s1.end(); p++)
        cout << *p << " ";
    cout << endl;
    return 0;
}